import request from '@/utils/request'
import { apiVersion } from '@/config'

// 全部部署
export function getAllDeployts(data) {
  return request({
    url: `/admin/${apiVersion}/edge/module/all`,
    method: 'get',
    data
  })
}
export function getDeploys(data) {
  return request({
    url: `/admin/${apiVersion}/edge/service/all`,
    method: 'get',
    data
  })
}
export function getDeploysMonitor(data) {
  return request({
    url: `/admin/${apiVersion}/edge/monitor`,
    method: 'get',
    data
  })
}
/**
 * 添加部署
 * @param {} data 
 */
export function addDeploy(data) {
  console.log("-------------" + JSON.stringify(data))
  return request({
    url: `/admin/${apiVersion}/edge/add`,
    method: 'post',
    data: data
  })
}
/**
 * 删除部署
 * @param {} data 
 */
export function delDeploy(data) {
  return request({
    url: `/admin/${apiVersion}/edge/${data.id}`,
    method: 'delete',
    data: data
  })
}
/**
 * 更新部署
 * @param {} data 
 */
export function putDeploy(data) {
  return request({
    url: `/admin/${apiVersion}/edge/${data.id}/update`,
    method: 'put',
    data: data
  })
}
/**
 * 取得部署
 * @param {*} data 
 */
export function getDeployDetail(data) {
  console.log(data);
  return request({
    url: `/admin/${apiVersion}/edge/${data.id}`,
    noLoadding: true,
    method: 'get',
  })
}
/**
 * 获取podname
 * @param {*} data 
 */
export function getServingPodName(data) {
  return request({
    url: `/admin/${apiVersion}/edge/${data.id}/podName`,
    noLoadding: true,
    method: 'get',
  })
}

/**
 * 启动
 * @param {*} id 
 */
export function startServing(id) {
  return request({
    url: `/admin/${apiVersion}/edge/${id}/start`,
    noLoadding: true,
    method: 'post',
  })
}
/**
 * 停止
 * @param {*} id 
 */
// export function stopServing(id) {
//   return request({
//     url: `/admin/${apiVersion}/edge/${id}/stop`,
//     noLoadding: true,
//     method: 'put',
//   })
// }

/**
 * 获取指标或图示数据详情
 * @param {*} data 
 */
export function metricData(data) {
  return request({
    url: `/admin/${apiVersion}/edge/${data.id}/metric/data`,
    noLoadding: true,
    headers: {
      "Content-Type": "application/x-www-form-urlencoded"
    },
    method: 'get',
    data
  })
}
/**
 * 获取指标或图示名称
 * @param {*} data 
 */
export function metricKeys(data) {
  return request({
    url: `/admin/${apiVersion}/edge/${data.id}/metric/keys`,
    noLoadding: true,
    headers: {
      "Content-Type": "application/x-www-form-urlencoded"
    },
    method: 'get',
    data
  })
}

/**
 * 获取全部边缘节点信息
 * @param {*} data
 */
export function getAllEdgeNode(data) {
  return request({
    url: `/admin/${apiVersion}/edge/all`,
    noLoadding: true,
    headers: {
      "Content-Type": "application/x-www-form-urlencoded"
    },
    method: 'get',
    data
  })
}
